<?php
/*
 * @Author: 18237136835 liequank@163.com
 * @Date: 2023-08-29 21:43:57
 * @LastEditors: 18237136835 liequank@163.com
 * @LastEditTime: 2023-09-06 16:12:47
 * @FilePath: \laraveDact\app\Admin\Controllers\HomeController.php
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

namespace App\Admin\Controllers;

use App\Admin\Metrics\Examples;
use App\Http\Controllers\Controller;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Layout\Column;
use App\Models\BoxUser;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;

class HomeController extends Controller
{
    public function index(Content $content)
    {
        return $content
            ->header('首页')
            ->body(function (Row $row) {
                $row->column(6, function (Column $column) {
                    // 创建Grid实例
                    $grid = new Grid(BoxUser::query());

                    // 配置表格
                    $grid->disableCreateButton()
                        ->disableActions()
                        ->disableRowSelector()
                        ->disablePagination()
                        ->paginate(5);
                    $grid->quickSearch('username')->placeholder('请搜索学生姓名')->auto(true);
                    
                    $grid->column('id', 'ID');
                    $grid->column('username', '姓名')->sortable();
                    $grid->column('integral', '积分')->sortable();
                    $grid->column('balance', '金额')->sortable();
                    $grid->column('createtime', '创建时间')->sortable();

                    // 将Grid数据传递给视图
                    $column->row(view('admin.home.index', compact('grid')));
                });
                
                $row->column(6, function (Column $column) {
                    $column->row(new Examples\ProductOrders());
                });

                $row->column(12, function (Column $column) {
                    $column->row(new Examples\MyBar());
                });
                // Card::make('我的图表', $column->row(new Examples\MyBar()));



            });
    }
}


// return $content
//             ->header('首页')
//             // ->description('Description...')
//             ->body(function (Row $row) {
//                 $row->column(6, function (Column $column) {
//                     $column->row(Dashboard::title());
//                     $column->row(new Examples\Tickets());
//                 });

//                 $row->column(6, function (Column $column) {
//                     $column->row(function (Row $row) {
//                         $row->column(6, new Examples\NewUsers());
//                         $row->column(6, new Examples\NewDevices());
//                     });

//                     $column->row(new Examples\Sessions());
//                     $column->row(new Examples\ProductOrders());
//                 });
//             });
//     }
